#include "stdafx.h"
#include "CProcessByteStreamReader.h"

/*!
* \brief
* Class CProcessByteStreamReader constuctor
* 
* \remarks
* Constuctor
* 
*/
CProcessByteStreamReader::CProcessByteStreamReader(DWORD dwPorcessID,
                                                   void * pBaseAddr) : IByteStreamReader(pBaseAddr)
{
    m_dwProcessId = 0;
    if(dwPorcessID == NULL)
        m_dwProcessId = GetCurrentProcessId();
    else
        m_dwProcessId = dwPorcessID;
}
/*!
* \brief
* Class AceSymBlderAttPropMgrHlper deconstuctor
* 
* \remarks
* Deconstuctor
* 
*/
CProcessByteStreamReader::~CProcessByteStreamReader()
{

}

bool CProcessByteStreamReader::ReadBytesFromMemAddr(void* resValue, size_t nSize)
{
    if(GetCurrentBaseAddr() == NULL)
        return false; 
    HANDLE hRemoteProcess;
    hRemoteProcess = OpenProcess( PROCESS_QUERY_INFORMATION | 
        PROCESS_VM_OPERATION | PROCESS_VM_READ | 
        PROCESS_VM_WRITE,FALSE, m_dwProcessId);
    ReadProcessMemory(hRemoteProcess, GetCurrentBaseAddr(), resValue, nSize, 0);
    CloseHandle(hRemoteProcess);
    return true;
}